/*
=======================================================================

  BOTS Captain Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_CAPTAIN_PROMOTE		100
#define BOTS_CAPTAIN_DEMOTE			101
#define BOTS_CAPTAIN_FIRESCI		102
#define BOTS_CAPTAIN_SCOUTALL		103
#define BOTS_CAPTAIN_SENDALARM		104
#define BOTS_CAPTAIN_TRACKER		105
#define BOTS_CAPTAIN_DROPPROMOTE	106
#define BOTS_CAPTAIN_UI_TEAMORDERS	107
#define BOTS_CAPTAIN_VIDEO			108
#define BOTS_CAPTAIN_WARCRY			109

typedef struct 
{
  menuframework_s menu;
  
  menutext_s	title;
  menutext_s	promote;
  menutext_s	demote;
  menutext_s	firesci;
  menutext_s	scoutall;
  menutext_s	sendalarm;
  menutext_s	tracker;
  menutext_s	droppromote;
  menutext_s	ui_teamorders;
  menutext_s	video;
  menutext_s	warcry;
  menutext_s	cancel;
} captainCommands_t;

static captainCommands_t		s_captain;

/*
=================
BOTS_CaptainCommandsMenu_Event
callback routine
=================
*/
void BOTS_CaptainCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_CAPTAIN_PROMOTE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "promote\n" );
		break;
	case BOTS_CAPTAIN_DEMOTE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "demote\n" );
		break;
	case BOTS_CAPTAIN_FIRESCI:
		trap_Cmd_ExecuteText( EXEC_APPEND, "firesci\n" );
		break;
	case BOTS_CAPTAIN_SCOUTALL:
		trap_Cmd_ExecuteText( EXEC_APPEND, "scoutall\n" );
		break;
	case BOTS_CAPTAIN_SENDALARM:
		trap_Cmd_ExecuteText( EXEC_APPEND, "sendalarm\n" );
		break;
	case BOTS_CAPTAIN_TRACKER:
		trap_Cmd_ExecuteText( EXEC_APPEND, "tracker\n" );
		break;
	case BOTS_CAPTAIN_DROPPROMOTE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "droppromote\n" );
		break;
	case BOTS_CAPTAIN_UI_TEAMORDERS:
		trap_Cmd_ExecuteText( EXEC_APPEND, "ui_teamorders\n" );
		break;
	case BOTS_CAPTAIN_VIDEO:
		trap_Cmd_ExecuteText( EXEC_APPEND, "video\n" );
		break;
	case BOTS_CAPTAIN_WARCRY:
		trap_Cmd_ExecuteText( EXEC_APPEND, "warcry\n" );		
		break;

	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_CaptainCommandsMenu_Init
=================
*/
void BOTS_CaptainCommandsMenu_Init() 
{
	int		y;
	memset( &s_captain, 0 ,sizeof(captainCommands_t) );
	s_captain.menu.wrapAround = qtrue;
	s_captain.menu.fullscreen = qfalse;

	y = 96;
	s_captain.title.generic.type	= MTYPE_PTEXT;
	s_captain.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_captain.title.generic.x		= 320;
	s_captain.title.generic.y		= y;
	s_captain.title.string			= "CAPTAIN COMMAND MENU";
	s_captain.title.color			= color_bots_menu;
	s_captain.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_captain.promote.generic.type		= MTYPE_PTEXT;
	s_captain.promote.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.promote.generic.x			= 320;
	s_captain.promote.generic.y			= y;
	s_captain.promote.generic.id		= BOTS_CAPTAIN_PROMOTE;
	s_captain.promote.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.promote.string			= "PROMOTE PLAYER - promote";
	s_captain.promote.color				= color_bots_menu;
	s_captain.promote.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_captain.demote.generic.type		= MTYPE_PTEXT;
	s_captain.demote.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.demote.generic.x			= 320;
	s_captain.demote.generic.y			= y;
	s_captain.demote.generic.id			= BOTS_CAPTAIN_DEMOTE;
	s_captain.demote.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.demote.string				= "DEMOTE PLAYER - demote";
	s_captain.demote.color				= color_bots_menu;
	s_captain.demote.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_captain.firesci.generic.type		= MTYPE_PTEXT;
	s_captain.firesci.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.firesci.generic.x			= 320;
	s_captain.firesci.generic.y			= y;
	s_captain.firesci.generic.id		= BOTS_CAPTAIN_FIRESCI;
	s_captain.firesci.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.firesci.string			= "FIRE SCIENTIST - firesci";
	s_captain.firesci.color				= color_bots_menu;
	s_captain.firesci.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_captain.scoutall.generic.type		= MTYPE_PTEXT;
	s_captain.scoutall.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.scoutall.generic.x		= 320;
	s_captain.scoutall.generic.y		= y;
	s_captain.scoutall.generic.id		= BOTS_CAPTAIN_SCOUTALL;
	s_captain.scoutall.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.scoutall.string			= "SCOUT TO TEAM - scoutall";
	s_captain.scoutall.color			= color_bots_menu;
	s_captain.scoutall.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_captain.sendalarm.generic.type		= MTYPE_PTEXT;
	s_captain.sendalarm.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.sendalarm.generic.x			= 320;
	s_captain.sendalarm.generic.y			= y;
	s_captain.sendalarm.generic.id			= BOTS_CAPTAIN_SENDALARM;
	s_captain.sendalarm.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.sendalarm.string				= "SEND ALARM - sendalarm";
	s_captain.sendalarm.color				= color_bots_menu;
	s_captain.sendalarm.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_captain.tracker.generic.type		= MTYPE_PTEXT;
	s_captain.tracker.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.tracker.generic.x			= 320;
	s_captain.tracker.generic.y			= y;
	s_captain.tracker.generic.id		= BOTS_CAPTAIN_TRACKER;
	s_captain.tracker.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.tracker.string			= "USE TRACKER - tracker";
	s_captain.tracker.color				= color_bots_menu;
	s_captain.tracker.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_captain.droppromote.generic.type		= MTYPE_PTEXT;
	s_captain.droppromote.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.droppromote.generic.x			= 320;
	s_captain.droppromote.generic.y			= y;
	s_captain.droppromote.generic.id		= BOTS_CAPTAIN_DROPPROMOTE;
	s_captain.droppromote.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.droppromote.string			= "DROP PROMO - droppromote";
	s_captain.droppromote.color				= color_bots_menu;
	s_captain.droppromote.style				= UI_CENTER|UI_SMALLFONT;

/*
	y += BOTS_VERTICAL_SPACING;
	s_captain.ui_teamorders.generic.type		= MTYPE_PTEXT;
	s_captain.ui_teamorders.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.ui_teamorders.generic.x			= 320;
	s_captain.ui_teamorders.generic.y			= y;
	s_captain.ui_teamorders.generic.id			= BOTS_CAPTAIN_UI_TEAMORDERS;
	s_captain.ui_teamorders.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.ui_teamorders.string				= "BOTS COMMANDS - ui_teamorders";
	s_captain.ui_teamorders.color				= color_bots_menu;
	s_captain.ui_teamorders.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_captain.video.generic.type		= MTYPE_PTEXT;
	s_captain.video.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.video.generic.x			= 320;
	s_captain.video.generic.y			= y;
	s_captain.video.generic.id			= BOTS_CAPTAIN_VIDEO;
	s_captain.video.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.video.string				= "TEAM CAMERA - video";
	s_captain.video.color				= color_bots_menu;
	s_captain.video.style				= UI_CENTER|UI_SMALLFONT;
*/

	y += BOTS_VERTICAL_SPACING;
	s_captain.warcry.generic.type		= MTYPE_PTEXT;
	s_captain.warcry.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.warcry.generic.x			= 320;
	s_captain.warcry.generic.y			= y;
	s_captain.warcry.generic.id			= BOTS_CAPTAIN_WARCRY;
	s_captain.warcry.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.warcry.string				= "WARCRY - warcry";
	s_captain.warcry.color				= color_bots_menu;
	s_captain.warcry.style				= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_captain.cancel.generic.type		= MTYPE_PTEXT;
	s_captain.cancel.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_captain.cancel.generic.x			= 320;
	s_captain.cancel.generic.y			= y;
	s_captain.cancel.generic.id			= BOTS_CANCEL;
	s_captain.cancel.generic.callback	= BOTS_CaptainCommandsMenu_Event; 
	s_captain.cancel.string				= "CANCEL";
	s_captain.cancel.color				= color_bots_menu;
	s_captain.cancel.style				= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_captain.menu, &s_captain.title );
	Menu_AddItem( &s_captain.menu, &s_captain.promote );
	Menu_AddItem( &s_captain.menu, &s_captain.demote );
	Menu_AddItem( &s_captain.menu, &s_captain.firesci );
	Menu_AddItem( &s_captain.menu, &s_captain.scoutall );
	Menu_AddItem( &s_captain.menu, &s_captain.sendalarm );
	Menu_AddItem( &s_captain.menu, &s_captain.tracker );
	Menu_AddItem( &s_captain.menu, &s_captain.droppromote );
	// Menu_AddItem( &s_captain.menu, &s_captain.ui_teamorders );
	// Menu_AddItem( &s_captain.menu, &s_captain.video );
	Menu_AddItem( &s_captain.menu, &s_captain.warcry );
	Menu_AddItem( &s_captain.menu, &s_captain.cancel );
}

void BOTS_CaptainCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_CaptainCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_captain.menu );
}
